package com.spring.model.jackson;
import java.io.IOException;

import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.Data;

public class JacksonTester {
   public static void main(String args[]){
      ObjectMapper mapper = new ObjectMapper();
      String jsonString = "{\"name\":\"Mahesh\", \"age\":21}";
      //map json to student
      try {
         Student student = mapper.readValue(jsonString, Student.class);
         System.out.println(student);
         jsonString = mapper.writeValueAsString(student);
         System.out.println(jsonString);

      } catch (IOException e) {
         e.printStackTrace();
      }
   }
}

@Data
class Student {
   private String name;
   private int age;	
}

